package wjh.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import wjh.pojo.ExamForm;
import wjh.pojo.Patient;
import wjh.service.RegisterService;
import wjh.service.ZlyExamFormService;
import wjh.service.ZlyPatientService;

import java.util.List;

@Controller
@RequestMapping("/patient")
public class ZlyPatientController {
    @Autowired
    private ZlyPatientService zlyPatientService;

    @Autowired
    private ZlyExamFormService zlyExamFormService;
    @Autowired
    private RegisterService registerService;
    @RequestMapping("/appoExam")
    public String appoExam(){
        return "appoExam";
    }

    @RequestMapping("/history")
    public ModelAndView history(@RequestParam("id") Integer id){
        Patient patient = registerService.findPatientById(id);
        String pname= patient.getName();
        List<ExamForm> examFormList = zlyExamFormService.findByPname(pname);
//        System.out.println(examFormList);

        ModelAndView modelAndView = new ModelAndView("history");
        modelAndView.addObject("patient", patient);
        modelAndView.addObject("examFormList", examFormList);
        return modelAndView;
    }
}
